@echo off
set SERVICE_NAME=DeepSeekService
set PYTHON_PATH="C:\Python310\python.exe"  # 修改为实际Python路径
set APP_PATH=%~dp0service.py

:: 使用NSSM创建服务
if not exist nssm.exe (
    echo 正在下载NSSM...
    powershell -Command "Invoke-WebRequest -Uri https://nssm.cc/ci/nssm-2.24-101-g897c7ad.zip -OutFile nssm.zip"
    powershell -Command "Expand-Archive nssm.zip -DestinationPath ."
    move nssm-2.24-101-g897c7ad\nssm.exe .
    rmdir /s /q nssm-2.24-101-g897c7ad
    del nssm.zip
)

nssm.exe install %SERVICE_NAME% %PYTHON_PATH% %APP_PATH%
nssm.exe set %SERVICE_NAME% AppDirectory %~dp0
nssm.exe set %SERVICE_NAME% DisplayName "DeepSeek Local Service"
nssm.exe set %SERVICE_NAME% Start SERVICE_AUTO_START

echo 服务安装完成，使用以下命令管理：
echo   net start %SERVICE_NAME%
echo   net stop %SERVICE_NAME%